package lzk.myshop.dao;

import lzk.myshop.pojo.OrderDetail;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;

import java.util.List;

@Mapper
public interface OrderDetailMapper {

    @Select("select * from `orderdetail` where `orderid` = #{orderid}")
    List<OrderDetail> getOrderDByOrderId(int orderid);

    @Insert("<script>" +
            "INSERT INTO orderdetail (`orderid`, `goodsid`, `goodsname`, `price`, `number`, `totalprice`, `sentaddress`,`merchantid`,`merchantname`) VALUES " +
            "<foreach collection='list' item='item' separator=','>" +
            "(#{item.orderid}, #{item.goodsid}, #{item.goodsname}, #{item.price}, #{item.number}, #{item.totalprice}, #{item.sentaddress},#{item.merchantid},#{item.merchantname})" +
            "</foreach>" +
            "</script>")
    int newOrder(@Param("list")List<OrderDetail> orderDetail);

//    @Select("selece * from `orderdetail` where `merchantid` = #{merid}")
//    List<OrderDetail> allMerOrderD(int merid);
}
